<template>
  <Card style="height:800px">
      <p slot="title" style="color: red;font-size: large;">
        <Icon type="pinpoint"></Icon>
        前端征信否决
      </p>
      <Row>
        <!--查询日期起、查询日期止、客户姓名、证件号码-->
        <DatePicker type="date" v-model="startCreatedDate" placeholder="查询日期(起)" style="width: 200px"></DatePicker>
        <DatePicker type="date" v-model="endCreatedDate" placeholder="查询日期(止)" style="width: 200px;margin-left: 10px;"></DatePicker>
        <Input v-model="custName" style="width: 200px;margin-left: 15px;" placeholder="客户姓名"></Input>
        <Input v-model="custCardNo" style="width: 200px;margin-left: 15px;" placeholder="身份证号码"></Input>
        <Button type="primary" @click="queryPage" style="margin-left: 15px;">查询</Button>
      </Row>
      <Table stripe border :columns="columns1" :data="data1" style="margin-top: 15px;"></Table>
      <div class="page-box">
        <Page :total="totalNumber" size="small" :current="currentPage" :page-size="pageSize" show-total @on-change="pageIndexChange"></Page>
      </div>
  </Card>
</template>
<script>
export default {
  data () {
    return {
      $ajax: null,

      path: this.$route.path,

      custName: '',
      custCardNo: '',
      startCreatedDate: null,
      endCreatedDate: null,
      totalNumber: 1, // 总记录数

      currentPage: 1, // 当前页码

      pageSize: 20, // 页大小

      columns1: [{
        align: 'center',
        type: 'index',
        width: 60,
        title: '序号'
      },
      {
        align: 'center',
        title: '客户姓名',
        key: 'custName'
      },
      {
        align: 'center',
        title: '进件号',
        key: 'loanId'
      },
      {
        align: 'center',
        title: '身份证号码',
        key: 'custCardNo'
      },
      {
        align: 'center',
        title: '贷款名称',
        key: 'productName'
      },
      {
        align: 'center',
        title: '所属渠道',
        key: 'channel'
      },
      {
        align: 'center',
        title: '客户经理',
        key: 'employeeName'
      },
      {
        align: 'center',
        title: '提交日期',
        key: 'createdDate',
        render: (h, params) => {
          var vm = this
          return h('div', [
            h('span', vm.$util.formatTime(params.row.createdDate))
          ])
        }
      },
      {
        align: 'center',
        title: '流程环节',
        key: 'curNodeCode',
        render: (h, params) => {
          var nodeCode = params.row.curNodeCode
          if (nodeCode === 'woCreditInspection') {
            return h('div', [
              h('span', '征信任务处理')
            ])
          } else if (nodeCode === 'woCreditLoadUp') {
            return h('div', [
              h('span', '征信报告上传')
            ])
          } else if (nodeCode === 'woCreditCheck') {
            return h('div', [
              h('span', '征信报告审核')
            ])
          }
        }
      },
      {
        align: 'center',
        title: '处理人',
        key: 'assignee'
      },
      {
        align: 'center',
        title: '操作',
        key: 'action',
        render: (h, param) => {
          const vm = this
          return h('div', {}, [
            h('Button', {
              props: {
                type: 'info',
                size: 'small'
              },
              style: {
                fontSize: '12px'
              },
              on: {
                'click' () {
                  var str = prompt('确定直接否决该笔业务？如确定，请输入否决原因。')
                  //
                  if (str === '') {
                    alert('请输入否决原因')
                    return
                  }
                  // 若点击取消 str为null
                  if (str != null) {
                    var params = {
                      loanId: param.row.loanId,
                      vetoReason: str
                    }

                    // 执行否决原因的代码操作
                    vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/vetoCase', params).then(re => {
                      var data = re.data
                      var code = data.code
                      if (code === 'success') {
                        vm.$Message.info('否决成功')
                        vm.queryPage()
                      }
                    }).catch(er => {

                    })
                  }
                }
              }
            }, '否决')
          ])
        }
      }
      ],
      data1: []

    }
  },

  methods: {
    pageIndexChange (pageIndex) {
      this.currentPage = pageIndex
      this.queryPage()
    },

    initPage () {
      this.queryPage()
    },

    queryPage () {
      const vm = this
      var params = {
        pageNum: vm.currentPage,
        pageSize: vm.pageSize,
        custCardNo: vm.custCardNo,
        channel: vm.channel,
        custName: vm.custName,
        curNodeCodes: ['woCreditInspection', 'woCreditLoadUp', 'woCreditCheck'],
        startCreatedDate: vm.startCreatedDate,
        endCreatedDate: vm.endCreatedDate
      }
      vm.$ajax.post(vm.$appContext.marvels_core_approve + '/approve/credit/report/service/creditList', params).then(re => {
        var data = re.data
        var code = data.code
        var message = data.message
        if (code !== 'success') {
          this.$Message.warning(message)
          return
        }
        vm.data1 = re.data.data.list
        vm.totalNumber = re.data.data.total
      }).catch(er => {

      })
    }

  },

  created () {
    // 初始化当前页面请求对象实例
    this.$ajax = this.$util.ajax()
    this.initPage()
  }
}
</script>

<style lang="less">
@import '../../../styles/common.less';
@import '../../../styles/table.less';
</style>
